<template>
	<view class="uni_box login">
		<!-- <navbar title='' backgroundColor='#566FFF'>
		</navbar> -->
		<view class="content">
			<image src="@/static/che/loginbg.jpg" mode="" class="loginbg"></image>
			<view class="loginview">
				<view class="loginitems">
					<image src="@/static/che/logo.png" mode="" class="logosbg"></image>
					<view class="listitem">
						<input class="iteminput" type="number" v-model="phonenumber" placeholder="请输入手机号码">
					</view>
					<view class="listitem">
						<input class="iteminput" type="number" v-model="registration" placeholder="请输入验证码">
						<text style="margin-left: auto;" v-if="isTimer">{{time}}s</text>
						<text  v-else class="fayan" @click="lockSheet">发送验证码</text>
					</view>
					<view class="listitem">
						<input class="iteminput" type="text" v-model="password" placeholder="请设置登录密码">
					</view>
					<view class="listitem">
						<input class="iteminput" type="text" v-model="pay" placeholder="请设置支付密码">
					</view>
					<view class="listitem">
						<input class="iteminput" type="text" v-model="nickName" placeholder="请输入姓名">
					</view>
					<view class="listitem">
						<input class="iteminput" type="text" v-model="email" placeholder="请输入邮箱">
					</view>
					<view class="item_desc">
						<view class="desctext">
							注册代表您已同意
							<text style="color: rgba(249,0,23,1);" @click.stop="routerTo('/pages/setting/article?key=agreement')">《用户协议》</text>
						</view>
					</view>
					<view class="bot">
						<view class="botbtn" @click="tozhuce">
							<view class="btnbgview">
								注册
							</view>
						</view>
						<text class="zhuce" @click="login">登录</text>
					</view>
					
				</view>
				
			</view>
			
			
			
		</view>
		<!-- <div id="cbox" style="width: 300px"></div> -->
		<!-- <yidunCaptcha ref="captcha" :isSense="false" @verify="handleCaptcha"></yidunCaptcha> -->
		<!-- <yidunCaptchas ref="captcha"></yidunCaptchas> -->
		<u-toast ref="uToast" />
	</view>
</template>
<!-- <script src="https://cdn.bootcss.com/babel-polyfill/7.4.3/polyfill.min.js"></script>
<script src="https://www.yunpian.com/static/official/js/libs/riddler-sdk-0.2.2.js?t=20210720"></script> -->
<script>
	
	export default {
		data() {
			return {
				phone: "",
				password: "",
				isyanzheng:false,
				checked:false,
				timer: null,
				time: 60,
				isTimer: false,
				iseyes:false,
				type_number: "text",
				type_password: "password",
				code:'',
				email:'',//邮箱
				pay:'',//支付密码
				password:'',//登录密码
				registration:'',//验证码
				inviter:'',//推荐人id
				phonenumber:'',//手机号
				nickName:'',//姓名
				
			}
		},
		onLoad(option) {
			if(option.inviter){
				this.inviter  = option.inviter
			}
		},
		onReachBottom: function() {},
		methods: {
			async tozhuce() {
				if (!this.phonenumber) {
					this.$u.toast("请输入手机号");
					return false;
				}
				if (!this.registration) {
					this.$u.toast("请输入验证码");
					return false;
				}
				if (!this.password) {
					this.$u.toast("请设置登录密码");
					return false;
				}
				if (!this.pay) {
					this.$u.toast("请设置支付密码");
					return false;
				}
				let res = await this.$u.api.register({
					phonenumber: this.phonenumber,
					registration: this.registration,
					password:this.password,
					pay:this.pay,
					email:this.email,
					inviter:this.inviter,
					nickName:this.nickName
				});
				console.log(res)
				// this.$store.commit('changeToken', token);
				this.$u.toast("注册成功");
				setTimeout(() => {
					// uni.switchTab({
					// 	url: '/pages/tabbar/my'
					// })
					// uni.navigateTo({
					// 	url: '/pages/tabbar/home'
					// })
				}, 1000);
			},
			async lockSheet() {
				let phone = this.phonenumber;
				if (!phone) {
					this.$refs.uToast.show({
						title: "请输入手机号码",
						type: "error"
					})
					return
				};
				this.isTimer = true;
				this.timer = setInterval(() => {
					this.time--
					if (this.time < 0) {
						this.isTimer = false;
						this.time = 60;
						clearInterval(this.timer);
					};
				}, 1000);
				let res = await this.$u.api.smsSend({
					phone: this.phonenumber
				});
				// this.initYpRiddler()
				// this.$refs.captcha.initYpRiddler();
				// this.$refs.captcha.verify();
			},
			async handleCaptcha(validate) {
				this.isTimer = true;
				this.timer = setInterval(() => {
					this.time--
					if (this.time < 0) {
						this.isTimer = false;
						this.time = 60;
						clearInterval(this.timer);
					};
				}, 1000);
				let res = await this.$u.api.smsSend({
					phone: this.phone,
					scene: "login",
					authenticate:validate.authenticate,
					token:validate.token
				});
			},
			backTo() {
				uni.navigateBack()
			},
			routerTo(url) {
				uni.navigateTo({
					url
				})
			},
			router(url) {
				uni.redirectTo({
					url
				})
				// uni.navigateTo({
				// 	url
				// })
			},
			checkboxChange(e) {
				console.log(e);
				this.checked = e.value
				console.log(this.checked)
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				console.log(e);
			},
			headclick(e){
				this.isyanzheng = e
			},
			eyesClick(){
				this.iseyes = !this.iseyes
				
				console.log(this.iseyes)
			},
			login(){
				uni.redirectTo({
					url:'/pages/login/login'
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	page{
		background-color: #fff;
	}
	.login {
		.slot_right {
			display: flex;
			align-items: center;

			.nav_img {
				width: 48rpx;
				height: 48rpx;
				margin-right: 26rpx;
			}
		}

		.content {
			position: relative;
			height: 130vh;
			// padding: 68rpx 30rpx 0;
			// box-sizing: border-box;
			.loginbg{
				position: absolute;
				z-index: 0;
				width: 100%;
				height: 100%;
			}
			.loginview{
				
				position: relative;
				padding: 20% 30rpx;
				width: 100%;
				height: 100%;
			}
			.loginitems{
				background-color: #fff;
				border-radius: 15rpx;
				padding-top: 30rpx;
				padding: 30rpx;
				.logosbg{
					width: 115px;
					height: 160px;
					text-align: center;
					display: block;
					margin: 0 auto 50rpx;
				}
			}
			.ltext{
				font-size: 36rpx;
				font-weight: 500;
				color: #3D3D3D;
				display: block;
				margin-bottom: 40rpx;
			}
			.contenthead{
				display: flex;
				flex-direction: column;
				align-items: center;
				.newlogo{
					width: 320rpx;
					height: 320rpx;
				}
			}
			.zhangnav{
				width: 360rpx;
				margin: 0 auto 40rpx;
				display: flex;
				flex-direction: row;
				.zhangnavitem{
					width: 50%;
					display: flex;
					flex-direction: column;
					align-items: center;
					.xian{
						width: 100%;
						height: 4rpx;
						background: #999999;
					}
					.tit{
						font-size: 28rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						display: inline-block;
						margin-bottom: 8rpx;
					}
					
				}
				.active .xian{
					background: #73FAB5;
				}
				.active .tit{
					color: #73FAB5;
					font-weight: bold;
				}
			}
			.listitem{
				width: 100%;
				height: 92rpx;
				// background: #222222;
				border: 2rpx solid #eee;
				border-radius: 10rpx;
				padding: 0 25rpx;
				margin-bottom: 36rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				.icon{
					width: 39rpx;
					height: 39rpx;
					margin-right: 15rpx;
					position: relative;
					top: -2rpx;
				}
				.qu{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					margin-right: 20rpx;
				}
				.iteminput{
					font-size: 28rpx;
					color: #333;
					width: 60%;
					height: 70%;
					background: #fff;
					border: none;
				}
				.iteminput:active{
					border: none;
				}
				.iteminput:focus {
				    outline:none;
				    border: none;
				}
				.yanright{
					margin-left: auto;
					display: flex;
					align-items: center;
				}
				.fayan{
					margin-left: auto;
					font-size: 26rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #fff;
					padding:10rpx 20rpx;
					background-color: rgba(249,0,23,1);
					border-radius: 10rpx;
				}
				.yan{
					// margin-left: auto;
					width: 44rpx;
					height: 44rpx;
				}
			}
            .zhuce{
				display: flex;
				flex-direction: row;
				
				.zhuceitem{
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999;
				}
				.zhuces{
					color: #73FAB5;
				}
				.wangji{
					margin-left: auto;
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			// 按钮样式开始
			.bot{
				margin-top: 60rpx;
				.botbtn{
					width: 100%;
					height: 88rpx;
					position: relative;
					.btnbg{
						width: 100%;
						height: 100%;
						position: absolute;
						z-index: 0;
					}
					.btnbgview{
						position: relative;
						z-index: 1;
						width: 92%;
						margin: 0 auto;
						height: 100%;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 28rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #fff;
						background-color: rgba(249,0,23,1);
						border-radius: 10rpx;
					}
				}
				.zhuce{
					color: rgba(249,0,23,1);
					display: block;
					text-align: center;
					margin-top: 20rpx;
					font-size: 24rpx;
					font-weight: 500;
				}
			}
			// 按钮样式结束
			.item_desc{
				margin-top: 36rpx;
				display: flex;
				align-items: center;
				width: 92%;
				margin: 36rpx auto 0;
				.desctext{
					display: flex;
					align-items: center;
					width: 100%;
					justify-content: center;
				}
			}
		}
	}
</style>
